I have this view which is in the Controller, and item is passed as a prop.
render () {
if (this.view) {
const { item } = this.props;
return <ViewComponent
item = {item}
/>;
}
}
I have this other function save() which creates and save the payload.
I need to pass this payload as well present it to the save function as a prop to my view so I can use it.
save () {
const payload = constructPayloadFunction();
createFunction({ payload });
}
How do I do that?
You have to create a function in you Controller
public createFunction(payload){....}
and pass this as a prop to your ViewComponent
if (this.view) {
const { item } = this.props;
return <ViewComponent
item = {item}
createFunction = {createFunction}
/>;
}
and finally, in your save function, just pass the result
const payload = constructPayloadFunction();
createFunction(payload);